from django.shortcuts import render
from dwebsocket.decorators import accept_websocket,require_websocket
import json


def index(request):
    return render(request, 'chat/index.html')

@accept_websocket
def room(request, room_name):
    if request.is_websocket():
        for msg in request.websocket:
            request.websocket.send(msg)

    else:
        return render(request, 'chat/room.html', {'room_name':room_name})


"""
def room(request,room_name):
    return render(request, 'chat/room.html', {'room_name':room_name})
"""